


//
//  AnimationGroupController.m
//  界面动画集
//
//  Created by YYY on 2017/7/3.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

#import "AnimationGroupController.h"

#import "CABasicAnimationController.h"
#import "CAKeyframeAnimationController.h"
#import "CASpringAnimationController.h"
#import "CATransitionViewController.h"
#import "CAAnimationGroupController.h"

#import "LoadingViewController.h"

@interface AnimationGroupController () <UITableViewDelegate,UITableViewDataSource>
{
    NSArray *titlesArray;
}
@property(nonatomic,strong)UITableView *animateTableView;

@end

@implementation AnimationGroupController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"基础动画";
    
    titlesArray = @[@"CABasicAnimation（基础动画）",@"CAKeyframeAnimation（关键帧动画）",@"CASpringAnimation（弹簧动画）",@"CATransition（转场动画）",@"CAAnimationGroup（动画组）",@"界面加载动画"];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.animateTableView];
    // Do any additional setup after loading the view.
}

-(UITableView *)animateTableView
{
    if (!_animateTableView)
    {
        _animateTableView = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
        _animateTableView.dataSource = self;
        _animateTableView.delegate = self;
    }
    return _animateTableView;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return titlesArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identify = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];
    if (!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identify];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.textLabel.text = titlesArray[indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        //基础动画
        CABasicAnimationController *basicAnimation = [[CABasicAnimationController alloc]init];
        [self.navigationController pushViewController:basicAnimation animated:YES];
    }
    else if (indexPath.row == 1)
    {
        //关键帧动画
        CAKeyframeAnimationController *keyframeAnimation = [[CAKeyframeAnimationController alloc]init];
        [self.navigationController pushViewController:keyframeAnimation animated:YES];
    }
    else if (indexPath.row == 2)
    {
        //弹簧动画
        CASpringAnimationController *springAnimationVC = [[CASpringAnimationController alloc]init];
        [self.navigationController pushViewController:springAnimationVC animated:YES];
    }
    else if (indexPath.row == 3)
    {
        //转场动画
        CATransitionViewController *transitionVC = [[CATransitionViewController alloc]init];
        [self.navigationController pushViewController:transitionVC animated:YES];
    }
    else if (indexPath.row == 4)
    {
        //动画组
        CAAnimationGroupController *animationGroupVC = [[CAAnimationGroupController alloc]init];
        [self.navigationController pushViewController:animationGroupVC animated:YES];
    }
    else
    {
        //加载动画
        LoadingViewController *loadingAnimationVC = [[LoadingViewController alloc]init];
        [self.navigationController pushViewController:loadingAnimationVC animated:YES];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
